/*
 * Copyright (c) 2007-2020 西安交通信息投资营运有限公司 版权所有
 */

package com.xci.edu.core.entity;

import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.afterturn.easypoi.excel.annotation.ExcelIgnore;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.github.lvyanyang.core.BaseEntity;
import com.github.lvyanyang.core.Const;
import com.github.lvyanyang.core.XCI;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.validator.constraints.Length;

import java.util.Date;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

/**
 * 学员学时汇总
 * @author 焦元义 jiaoyuanyi@xci96716.com
 * @since 2020-11-24 15:14:37
 */
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(description = "学员学时汇总")
public class EduStudentPeriodSummary extends BaseEntity {
    /**
     * 学员主键
     */
    @JsonSerialize(using = ToStringSerializer.class)
    @NotNull(message = "学员主键不能为空")
    @Excel(name = "学员主键", width = 20d)
    @ApiModelProperty(value = "学员主键", required = true, position = 1)
    private Long studentId;

    /**
     * 课件主键
     */
    @JsonSerialize(using = ToStringSerializer.class)
    @NotNull(message = "课件主键不能为空")
    @Excel(name = "课件主键", width = 20d)
    @ApiModelProperty(value = "课件主键", required = true, position = 2)
    private Long coursewareId;

    /**
     * 课件名称
     */
    @JsonSerialize(using = ToStringSerializer.class)
    @ApiModelProperty(value = "课件主键", required = true, position = 3)
    private String coursewareName;

    /**
     * 课件类型[0-图片, 1-视频]
     */
    @Length(max = 50, message = "课件类型长度不能超过{max}个字符")
    @Excel(name = "课件类型", width = 20d, replace = { "图片_0", "视频_1" })
    @ApiModelProperty(value = "课件类型[0-图片, 1-视频]", required = true, position = 6)
    private String courseType;

    /**
     * 学时(秒)
     */
    @NotNull(message = "学时(秒)不能为空")
    @Excel(name = "学时(秒)", width = 20d)
    @ApiModelProperty(value = "学时(秒)", required = true, position = 4)
    private Integer period;

    /**
     * 课程总学时学时(秒)
     */
    @ApiModelProperty(value = "学时(秒)", required = true, position = 5)
    private Integer allPeriod;

    @ApiModelProperty("已学学时(时分秒)")
    public String getPeriodToText() {
        if (XCI.isBlank(period))
            return "0";
        else
        return  XCI.toJsonString(period /3600) + "小时" +XCI.toJsonString(period % 3600 / 60)  + "分" + XCI.toJsonString(period % 3600 % 60)  + "秒";
    }

    @ApiModelProperty("本章节学时(时分秒)")
    public String getAllPeriodToText() {
        if (XCI.isBlank(allPeriod))
            return "0";
        else
        return  XCI.toJsonString(allPeriod /3600) + "小时" +XCI.toJsonString(allPeriod % 3600 / 60)  + "分" + XCI.toJsonString(allPeriod % 3600 % 60)  + "秒";
    }

}
